<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<h1>字符串属性给元素赋值</h1>
<div>
    th:'元素属性'="${'modelMap对象属性'}"
</div>
<p th:text="${userName}" />
<input th:value="${userName}" />
<img th:src="${url}" />
<h1>date格式化</h1>
<input th:value="${#dates.format(date, 'yyyy-MM-dd hh:mm:ss')}" />

<h1>對象</h1>
<p>名字:<span th:text="${map.userName}"></span></p>
<p>年龄:<span th:text="${map.age}"></span></p>
<p>名字:年龄:<span th:text="${map.userName + '：' + map.age}"></span></p>

<h1>循环</h1>
<div th:each="map,mapStat :${list}">
    <p th:text="'第' + ${mapStat.count} + '个用户'" />
    <p>名字:<span th:text="${map.userName}"></span></p>
    <p>年龄:<span th:text="${map.age}"></span></p>
    <p>名字:年龄:<span th:text="${map.userName + '：' + map.age}"></span></p>
</div>


<h1>判断1</h1>
<div th:switch="${userName}">
    <p th:case="'刘志强'">存在刘志强</p>
    <p th:case="'王妍'">存在王妍</p>
    <p th:case="*">不存在任何人</p>
</div>

<h1>判断2</h1>
<span th:if="${userName} == '刘志强'" th:text="${userName}">  </span><br />


<h1>判断3</h1>
<span th:text="${userName == '王妍' ? '王妍' : '刘志强'}">  </span><br />
</body>
<script th:inline="javascript">
    // 赋值给js对象
    var map = /*[[${map}]]*/null;
    alert(JSON.stringify(map));
</script>
</html>